package main

import (
	"context"
	"log"
	"reflect"
	"strings"
	"time"
)

type TestContext struct {
	Req  map[string]interface{}
	Uid  int32
	Name string
}

func (TestContext) Deadline() (deadline time.Time, ok bool) {
	return time.Now(), true
}

func (TestContext) Done() <-chan struct{} {
	return nil
}

func (TestContext) Err() error {
	return nil
}

func (TestContext) Value(key interface{}) interface{} {
	return nil
}

func main() {
	log .Print(strings.Join([]string{"1","2","3"},","))

	t := map[int]bool{
		1: true,
		2: false,
		3: true,
		5: false,
	}
	isl := []int64{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
	tMap := map[string]interface{}{}
	tMap["1"] = "Shit"
	tMap["2"] = "Hello"

	cs := TestContext{tMap, 1, "name"}
	c, _ := context.WithTimeout(cs, time.Second*3)
	go func(c context.Context) {
		log.Print(reflect.ValueOf(c))
		log.Print(c.Deadline())
		select {
		case <-c.Done():
			dead, ok := c.Deadline()
			if ok {
				log.Print(dead)
				log.Print("1")
				log.Print(c.Deadline())
				if time.Now().Add(time.Microsecond).After(dead) {
					log.Print("expired")
				} else {
					log.Print("3")
					log.Print(c.Deadline())
					log.Print("cancel")
				}
			} else {
				log.Print("3")
				log.Print(c.Deadline())
				log.Print("cancel")
			}
		}
	}(c)
	log.Print(isl[0:4], isl[5:7])
	log.Print(append(isl[0:4], isl[5:7]...))
	log.Print(t)
	for k, _ := range t {
		delete(t, k)
	}
	log.Print(t)
	for true {
		time.Sleep(time.Second)
	}
}
